<?php
$script = "
$('body').delegate('.active-in-revision select', 'change', function(){
    var revision = $(this).val();
    var workflow_id = $(this).attr('id').replace('revision_', '');
    jQuery.get('".$this->createUrl('/Core/service/ajax', array('SID'=>'Cms.workflow.activePage'))."', {'revision_id' : revision, 'workflow_id' : workflow_id, 'page_id' : ".$this->pageId."}, function(data){
        $('#workflow-grid .filters input:first').trigger('change');
    });
});
";
Yii::app()->clientScript->registerScript(__CLASS__.'#WorkflowChangeRevision', $script);
$this->breadcrumbs=array(
	'Workflows'=>array('index'),
	'Manage',
);
?>
<?php $grid = $this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'workflow-grid',
    'dataProvider'=>$dataProvider,
    'filter'=>$model,
    'columns'=>array(
        'name',
        array(
            'name'=>'url',
            'value'=>'Yii::app()->controller->getPageUrl($data)',
            'type'=>'raw',
        ),
        array(
            'name'=>'site_id',//use site_id column store page revision active
            'value'=>'Yii::app()->controller->revisionDDList($data->id)',
            'filter'=>$this->revisions,
            'header'=>'Revision',
            'type'=>'raw',
            'htmlOptions'=>array(
                'class'=>'active-in-revision',
            ),
        ),
        array(
            'name'=>'type',
            'value'=>'$data->type == Workflow::TYPE_FINAL ? "Live" : ($data->type == Workflow::TYPE_INITITAL ? "Dev" : "")',
            'filter'=>false,
        ),
        'locale_id',
        array(
            'class'=>'CButtonColumn',
            'template'=>'{goto}',
            'buttons'=>array(
                'goto'=>array(
                    'label'=>'Go to',
                    'url'=>'Yii::app()->controller->getPageUrl($data)',
                    'imageUrl'=>Yii::app()->theme->baseUrl.'/images/link-go.png',
                    'options'=>array('target'=>'_blank'),
                ),
            )
        ),
    ),
)); 

?>

